﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using Telerik.Web.UI.HtmlChart;
using SMBCFamilyAssessment.Logic;
using System.Diagnostics;

namespace SMBCFamilyAssessment.Models
{
    public partial class AssessmentOutcomeRadarlineSeries : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            ChartData cData1 = null
                , cData2 = null;
              RadarLineSeries firstSeries=null;
              RadarLineSeries secondSeries=null;

            //  List<AssessmentSession> assessmentsdata = new List<AssessmentSession>();
            List<DateTime> datesList= new List<DateTime>();


           AssessmentBLcs Bl=new SMBCFamilyAssessment.Logic.AssessmentBLcs();

           //pass person id and assessment type to get last two assessment results for comparison
           datesList = Bl.getMaxDates(1, 1);


           if (datesList.Count > 1)
           {
               if (datesList[0] != null)
               {
                   cData1 = Bl.GetData(datesList[0], 1);

                   firstSeries = RadarAreaChart.PlotArea.Series[0] as Telerik.Web.UI.RadarLineSeries;
                firstSeries.Name = (datesList[0].Date.ToString()).Substring(0, 10);
               }

               if (datesList[1] != null)
               {
                   cData2 = Bl.GetData(datesList[1].Date, 1);

                   secondSeries = RadarAreaChart.PlotArea.Series[1] as Telerik.Web.UI.RadarLineSeries;
                  secondSeries.Name = (datesList[1].Date.ToString()).Substring(0, 10);
               }
              
               
           }

            if(cData1.QuestionsDictionary.Count>1)

            foreach (var item in cData1.QuestionsDictionary)
            {

                RadarAreaChart.PlotArea.XAxis.Items.Add(item.Value);

            }

            if (cData1.ScoresDictionary.Count > 1)
            foreach(var item in cData1.ScoresDictionary)
            {
                Debug.Write("First series data " + Environment.NewLine );
                Debug.Write("  Key : "+ item.Key + " Value " + item.Value +Environment.NewLine);
                firstSeries.SeriesItems.Add(item.Value);    
                
            }

            if (cData2.ScoresDictionary.Count > 1)
            foreach (var item in cData2.ScoresDictionary)
            {
                Debug.Write("Second series data " + Environment.NewLine);
                Debug.Write("  Key : " + item.Key + " Value " + item.Value + Environment.NewLine);
                secondSeries.SeriesItems.Add(item.Value);

            }



        }


    }
}


















//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Web.UI;
//using System.Web.UI.WebControls;
//using Telerik.Web.UI;
//using Telerik.Web.UI.HtmlChart;
//namespace SMBCFamilyAssessment.Models
//{
//    public partial class AssessmentOutcome : System.Web.UI.Page
//    {
//        protected void Page_Load(object sender, EventArgs e)
//        {


//            // SMBCFamilyAssessment.Logic.AssessmentBLcs.
//            //  List<AssessmentSession> assessmentsdata = new List<AssessmentSession>();


//            SMBCFamilyAssessment.Logic.AssessmentBLcs assessmentsdata = new SMBCFamilyAssessment.Logic.AssessmentBLcs();
//            assessmentsdata.GetAssessmentData();

//            RadarAreaChart.PlotArea.XAxis.Items.Add("A Might");
//            RadarAreaChart.PlotArea.XAxis.Items.Add("Intellect");

//            RadarAreaChart.PlotArea.XAxis.Items.Add("Personality");

//            RadarAreaChart.PlotArea.XAxis.Items.Add("Endurance");

//            RadarAreaChart.PlotArea.XAxis.Items.Add("Accuracy");

//            RadarAreaChart.PlotArea.XAxis.Items.Add("Speed");

//            RadarAreaChart.PlotArea.XAxis.Items.Add("A Luck");
//            RadarAreaSeries firstSeries =
//            RadarAreaChart.PlotArea.Series[0] as Telerik.Web.UI.RadarAreaSeries;
//            firstSeries.Name = "Atif";
//            firstSeries.SeriesItems[0].Y = 22;
//            firstSeries.SeriesItems[1].Y = 7;
//            firstSeries.SeriesItems[2].Y = 5;
//            firstSeries.SeriesItems[3].Y = 16;
//            firstSeries.SeriesItems[4].Y = 11;
//            firstSeries.SeriesItems[5].Y = 15;
//            firstSeries.SeriesItems[6].Y = 11;




//            RadarAreaSeries SecondSeries =
//      RadarAreaChart.PlotArea.Series[1] as Telerik.Web.UI.RadarAreaSeries;
//            SecondSeries.Name = "James";
//            SecondSeries.SeriesItems[0].Y = 15;
//            SecondSeries.SeriesItems[1].Y = 9;
//            SecondSeries.SeriesItems[2].Y = 10;
//            SecondSeries.SeriesItems[3].Y = 11;
//            SecondSeries.SeriesItems[4].Y = 14;
//            SecondSeries.SeriesItems[5].Y = 20;
//            SecondSeries.SeriesItems[6].Y = 21;





//            //<Series>
//            //    <telerik:RadarAreaSeries Name="Knight">
//            //        <Appearance>
//            //            <FillStyle BackgroundColor="#f45262"></FillStyle>
//            //        </Appearance>
//            //        <LabelsAppearance Visible="false"></LabelsAppearance>
//            //        <MarkersAppearance Visible="false" />
//            //        <SeriesItems>
//            //            <telerik:CategorySeriesItem Y="22"></telerik:CategorySeriesItem>
//            //            <telerik:CategorySeriesItem Y="7"></telerik:CategorySeriesItem>
//            //            <telerik:CategorySeriesItem Y="5"></telerik:CategorySeriesItem>
//            //            <telerik:CategorySeriesItem Y="16"></telerik:CategorySeriesItem>
//            //            <telerik:CategorySeriesItem Y="11"></telerik:CategorySeriesItem>
//            //            <telerik:CategorySeriesItem Y="15"></telerik:CategorySeriesItem>
//            //            <telerik:CategorySeriesItem Y="11"></telerik:CategorySeriesItem>
//            //        </SeriesItems>
//            //    </telerik:RadarAreaSeries>


//        }


//    }
//}